#!/bin/sh
. $HOME/.config/defaultprograms.txt
case "$1" in
 -default)
 echo $EMAIL > $HOME/.config/tmp/mail
 
 programchooser $EMAIL gtk-preferences "Email|WebBrowser" None > $HOME/.config/tmp/email
 cat $HOME/.config/defaultprograms.txt | grep -v EMAIL > $HOME/.config/defaultprograms.new
 EMAIL="`cat $HOME/.config/tmp/email`"
 [ "$EMAIL" = "" ] && EMAIL="cat $HOME/.config/tmp/mail"
 echo EMAIL=\"$EMAIL\" >> $HOME/.config/defaultprograms.new
 mv -f $HOME/.config/defaultprograms.new $HOME/.config/defaultprograms.txt
 rm -f $HOME/.config/tmp/mail
 rm -f $HOME/.config/tmp/email
 ;;
 *)
 exec $EMAIL "$@"
 ;;
esac
